using System.Collections.ObjectModel;
using DesignPattern.Models;
using DesignPattern.Views.Pages;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using DesignPattern.Services;
using Wpf.Ui.Controls;

namespace DesignPattern.ViewModels.Pages;

public partial class CreationalViewModel : ObservableObject
{
    private readonly DesignPatternService _designPatternService;
    [ObservableProperty] 
    private ObservableCollection<NavigationCard> _navigationCards = new ObservableCollection<NavigationCard>();
    
    public CreationalViewModel(DesignPatternService designPatternService)
    {
        _designPatternService = designPatternService;
        InitializeNavigationCards();
    }
    private void InitializeNavigationCards()
    {
        // 从designPatternService中获取创建型模式数据
        var creationalPatterns = _designPatternService.GetPatternsByType(PatternType.Creational);
        
        // 清空现有集合
        NavigationCards.Clear();
        // 为每个创建型模式创建导航卡片
        foreach (var pattern in creationalPatterns)
        {
            NavigationCards.Add(new NavigationCard
            {
                Name = pattern.Name,
                Icon = SymbolRegular.Fluent24, // 使用固定图标
                Description = pattern.Description,
                TargetPageTag = pattern.Name
            });
        }
    }
}